import { createApp } from 'vue'
import NotificationContainer from '@/components/NotificationContainer.vue'
import vuetify from '@/plugins/vuetify'

let mounted = false

export function initNotificationContainer() {
  if (mounted || typeof document === 'undefined') return
  const id = 'f2-notifications-root'
  if (document.querySelector('#' + id)) {
    mounted = true
    return
  }
  const el = document.createElement('div')
  el.id = id
  document.body.append(el)
  const app = createApp(NotificationContainer)
  app.use(vuetify)
  app.mount(el)
  mounted = true
}
